#include<bits/stdc++.h>
using namespace std;
int n,t,ans,kk;
double chao[100005];
double d[100005],a[100005],v[100005],p[100005],pl,man,pp[100005];
int ans4;
double S(double v,double t,double a){
    return v*t+0.5*a*t*t;
}
double vshun(double vchu,double s,double a){
    return sqrt(vchu*vchu+2*a*s);
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    for(int l=1;l<=t;l++){
        int n,m,L,V;
        memset(d,0,sizeof(d));
        memset(d,0,sizeof(a));
        memset(d,0,sizeof(v));
        memset(d,0,sizeof(p));
        memset(d,0,sizeof(pp));
        memset(d,0,sizeof(chao));
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
        }
        for(int i=1;i<=m;i++){
            cin>>p[i];
        }
        ans=0;
        for(int i=1;i<=n;i++){
           if(a[i]==0){
                if(v[i]>V){
                    for(int j=1;j<=m;j++){
                        if(a[i]<=p[j]){
                            chao[i]++;
                        }
                    }
                }

           }
           else {
                    for(int j=1;j<=m;j++){
                        if(d[i]<=p[j]){
                            if(vshun(v[i],p[j]-d[i],a[i])>V){
                                chao[i]++;
                            }
                        }
                    }

                }
           }
           for(int i=1;i<=n;i++){
                if(chao[i]>=1) ans++;
           }
           memset(d,0,sizeof(chao));
           while(pp[0]==0){

                for(int ppp=1;ppp<=m;ppp++){

                    if(pp[ppp]==0){
                        ans4=0;
                        for(int i=1;i<=n;i++){
           if(a[i]==0){
                if(v[i]>V){
                    for(int j=1;j<=m;j++){
                            if(j!=ppp)
                        if(a[i]<=p[j]){
                            chao[i]++;
                        }
                    }
                }

           }
           else {
                    for(int j=1;j<=m;j++){
                            if(j!=ppp)
                        if(d[i]<=p[j]){
                            if(vshun(v[i],p[j]-d[i],a[i])>V){
                                chao[i]++;
                            }
                        }
                    }

                }
           }
           pl=0;
           for(int i=1;i<=n;i++){
                if(chao[i]>=1) ans4++;
           }
           if(ans4==ans){
            for(int i=1;i<=m;i++){
                if(pp[i]==0) pl++;
            }
            man=max(pl,man);
            pl=0;
           }
                    }
                }
                int uu=m;
                while(pp[uu]!=0) uu--;
                pp[uu]=1;
                for(int kk=uu+1;kk<=m;kk++){
                    pp[kk]=0;
                }
           }
           cout<<ans<<" ";
           cout<<man<<endl;

    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}

